home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
tcl
/
tclm_1_0.lha
/
tclm-1.0
/
m1to0
< prev
next >
Wrap
Text File
|
1993-08-16
|
1KB
|
56 lines
#!/usr/local/bin/tclm -f
if {[string compare [lindex $argv 0] -f] == 0} {
set argc [expr {$argc - 2}]
set argv [lrange $argv 2 end]
}
if {$argc > 2} {
puts stderr "usage: m1to0 [infile [outfile]]"
exit 1
}
set in_file stdin
set out_file stdout
if {$argc > 0} {
set in_file_name [lindex $argv 0]
if {[catch {open $in_file_name "r"} in_file]} {
puts stderr "Couldn't open $in_file_name: $in_file"
exit 1
}
if {$argc > 1} {
set out_file_name [lindex $argv 1]
if {[catch {open $out_file_name "w"} out_file]} {
puts stderr "Couldn't open $out_file_name: $out_file"
exit 1
}
}
}
if {[catch {midiread $in_file} in_mfile]} {
puts stderr "Couldn't read MIDI file: $in_mfile"
exit 1
}
set num_tracks [midiconfig $in_mfile tracks]
for {set i 0} {$i < $num_tracks} {incr i} {
lappend track_list "$in_mfile $i 1"
}
set out_mfile [midimake]
midiconfig $out_mfile format 0
midiconfig $out_mfile tracks 1
midiconfig $out_mfile division [midiconfig $in_mfile division]
set delta [midimerge "$out_mfile 0" $track_list 0]
midiput $out_mfile 0 $delta metaeot
if {[catch {midiwrite $out_mfile $out_file} err]} {
puts stderr "Couldn't write format 0 MIDI file: $err"
exit 1
}
midifree $in_mfile
midifree $out_mfile
close $in_file
close $out_file
exit 0